package com.mezz.bones.im.logic.domain.enums;

import com.mezz.bones.im.common.exception.ImBaseException;
import com.mezz.bones.im.common.result.ImResultCode;

/**
 * @Author: zhuang
 * @Date: 2025/6/11 18:23
 * @Description: TODO
 * @Version: 1.0
 **/

public enum GroupMemberRoleEnum {

    /**
     * 普通成员
     */
    NORMAL("normal", "普通成员"),

    /**
     * 管理员
     */
    ADMIN("admin", "管理员"),
    /**
     * 群主
     */
    OWNER("owner", "群主");

    private String role;
    private String roleName;

    GroupMemberRoleEnum(String role, String roleName) {
        this.role = role;
        this.roleName = roleName;
    }

    public String getRole() {
        return role;
    }

    public void setRole(String role) {
        this.role = role;
    }

    public String getRoleName() {
        return roleName;
    }

    public void setRoleName(String roleName) {
        this.roleName = roleName;
    }

    public static GroupMemberRoleEnum getEnumByRole(String role) {
        for (GroupMemberRoleEnum value : GroupMemberRoleEnum.values()) {
            if (value.getRole().equals(role)) {
                return value;
            }
        }

        throw new ImBaseException(ImResultCode.DATA_NOT_FOUND, "角色不存在:" + role + ",请检查");
    }
}
